
		<div class='row'>
			<div class='col-md-12'>
				<div class='box box-info'>
					<div class='box-header'>
						<!-- tools box --><br>
						<table width='100%'>
							<tr>
								<td width='10%'>&nbsp;&nbsp;Kepada</td>
								<td width='1%'>&nbsp;</td>
								<td><input type="text" name="kepada" id="kepada" class="form-control" style="width:500px"; >
								</td>
							</tr>
							<tr>
								<td width='10%'>&nbsp;&nbsp;Judul Memo</td>
								<td width='1%'>&nbsp;</td>
								<td><input type="text" name="judul" id="judul" class="form-control" style="width:500px"; >
								</td>
							</tr>
						</table>
					</div><!-- /.box-header -->
					<div class='box-body pad'>
							<textarea id="editor1" name="editor1" rows="10" cols="80" placeholder="Silahkan menulis memo">
							</textarea>
							<table width='100%' class="table table-bordered">
							<tr>
								<td>Lampiran</td>
								<td><input type="file" id="attach1" onchange="upload(this)"></td>
								<td><input type="file" id="attach2" onchange="upload(this)"></td>
								<td><input type="file" id="attach3" onchange="upload(this)"></td>
								<td><input type="file" id="attach4" onchange="upload(this)"></td>
							</tr>
							</table>
							
							<br>      
							<button class="btn btn-primary btn-sm" style="width:60px" id="simpan" onclick="kirim()">Kirim</button>&nbsp;&nbsp<button class="btn btn-primary btn-sm" style="width:60px" id="simpan" onclick="batal()">Batal</button>
					</div>
				</div><!-- /.box -->

			</div><!-- /.col-->
		</div><!-- ./row -->


        <!-- jQuery 2.0.2 -->
        <script src="<?php echo base_url(); ?>js/jquery.min.js"></script>
        <!-- CK Editor -->
        <script src="<?php echo base_url(); ?>js/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
        <!-- Bootstrap WYSIHTML5 -->
        <script src="<?php echo base_url(); ?>js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function() {
                // Replace the <textarea id="editor1"> with a CKEditor
                // instance, using default configuration.
                CKEDITOR.replace('editor1');
                //bootstrap WYSIHTML5 - text editor
                //$(".textarea").wysihtml5();
            });
        </script>



    <link rel="stylesheet" href="<?php echo base_url(); ?>autocomplete/jquery-ui.css">
    <script src="<?php echo base_url(); ?>autocomplete/jquery-1.10.2.js"></script>
	
	<script>
	$(function() {
		var availableTags = [];
		loaduser();

		function split( val ) {
			return val.split( /,\s*/ );
		}
		function extractLast( term ) {
			return split( term ).pop();
		}

		function loaduser(){
			$.ajax({
				type: "POST",
				url: '<?php echo site_url(); ?>/memo/loaduser',
				data: ({param:1}),
				dataType:"json",
				success:function(data){
					availableTags=data;	
				}
			});		
		}	

		$( "#kepada" )
			.bind( "keyup", function( event ) {
				//loaduser();
				if ( (event.keyCode === $.ui.keyCode.TAB) && ($(this).autocomplete( "instance" ).menu.active) ) {
					event.preventDefault();
				}
			})
			.autocomplete({
				minLength: 0,
				source: function( request, response ) {
					response( $.ui.autocomplete.filter(availableTags, extractLast( request.term ) ) );
				},
				focus: function() {
					return false;
				},
				select: function( event, ui ) {
					var terms = split( this.value );
					terms.pop();
					terms.push( ui.item.value );
					terms.push( "" );
					this.value = terms.join( ", " );
					return false;
				}
			});
	});

	function kirim(){
		var ckepada =document.getElementById('kepada').value;
		var cjudul  =document.getElementById('judul').value;
		var cisi    =CKEDITOR.instances['editor1'].getData();
		var cfile1  =document.getElementById('attach1').value;
		var cfile2  =document.getElementById('attach2').value;
		var cfile3  =document.getElementById('attach3').value;
		var cfile4  =document.getElementById('attach4').value;
//		alert(cfile1);

		if(ckepada==''){
			alert('Tujuan Belum Diisi');
			exit;
		}

		$.ajax({
			type: 'POST',
			url: '<?php echo site_url(); ?>/memo/kirim',
			data: ({kepada:ckepada,judul:cjudul,isi:cisi,file1:cfile1,file2:cfile2,file3:cfile3,file4:cfile4}),
			dataType:'json',
			success:function(data){
				kosong();
				alert('Memo Telah Dikirim');	
			}
		});		

	}

	function kosong(){
	
		document.getElementById('kepada').value='';
		document.getElementById('judul').value='';
		document.getElementById('attach1').value='';
		document.getElementById('attach2').value='';
		document.getElementById('attach3').value='';
		document.getElementById('attach4').value='';
		CKEDITOR.instances['editor1'].setData('');

	}

	function upload(attach){	
		var imgfile = attach;  
		var namafile = attach.value;  
		formdata = new FormData(); 
		formdata.append("attach1",imgfile.files[0]);
		$.ajax({  
			url: "<?php echo base_url(); ?>/index.php/memo/do_upload/"+namafile,  
			type: "POST",  
			data: formdata,  
			dataType: "json",
			processData: false,  
			contentType: false,  
			success: function (data) {  
					//alert(data.file_name); 
					alert('Lampiran Berhasil Ditambahkan');
			}  
		});  
	} 
	
	</script>

